<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\BannerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '晒单';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="banner-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'content',
            [
                'attribute'=>'showpics',
                'format' => 'raw',
                'value'=>function($model){
                    /* @var $showpic \app\models\Showpic*/
                    $str = '';
                    foreach($model->showpics as $showpic){
                        $str.= Html::img(\app\models\UploadForm::SHOW_DIR.$showpic->url,['width'=>'40px','height'=>'40px']);
                    }
                    return $str;
                },
                'label'=>'图片',
                'filter'=>false,
            ],
            [
                'attribute' => 'created_at',
                'format' => ['date', 'php:Y-m-d']
            ],
            [
                'attribute' => 'updated_at',
                'format' => ['date', 'php:Y-m-d']
            ],

            [
                'class' => 'yii\grid\ActionColumn',
                'template'=>'{view}',
            ],

        ],
    ]); ?>
</div>
